<?php
error_reporting(0);
$isadmin=1;
include_once '../comm/config.php';
include_once 'include/page.class.php';
include_once '../comm/checkpostandget.php';
include_once 'check.php';
$keyword=$_GET['keyword']; 
$dj=$_GET['dj']; 
$px=$_GET['px'];
if($px=="")$px=1;
$page = !($_GET['page'])?'1':intval($_GET['page']);
$pagesize=10;
$page2=($page-1)*$pagesize;

$subsql="";
if($dj!="")
{
	$subsql=" and level=".$dj." ";
}
$subsql2="";
if($px=="1"){$subsql2=" tuijian desc,level desc,";}
if($px=="0"){$subsql2=" tuijian desc,level asc,";}
$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) {
	die(ERR_DB);
}
else
{
	mysql_query("set names utf8");
	$sql="select * from ".$BIAOTOU."shop where (nick like '%".$keyword."%' or title like '%".$keyword."%') ".$subsql;
	mysql_select_db($dbname);
	$rs = mysql_query($sql);
	$total = mysql_num_rows($rs);	
	
	$sql="select * from ".$BIAOTOU."shop where (nick like '%".$keyword."%' or title like '%".$keyword."%' )".$subsql." order by ".$subsql2." addtime desc limit ".$page2.",".$pagesize;
	$rs = mysql_query($sql);
}	
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
.STYLE2 {
	color: #555555;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
-->
</style>
<script language="javascript" type="text/javascript">
function SelectAll()
{
  var e = event.srcElement;
  var inputs = document.forms[1].elements;
  for (var i=0; i < inputs.length; i++)
	if (inputs[i].type == "checkbox" && inputs[i].name.indexOf("fu[]") >=0)
	inputs[i].checked = e.checked;
}
function showconfirm(id)
{
	var flag=false; //是否有选择职位信息
	var k=0;
	var refid;
	for(i=0;i<document.thisForm.elements.length;i++) 
	{
		if (document.thisForm.elements[i].name=="fu[]")
		{		
			if (document.thisForm.elements[i].checked==true) 
			{
				flag=true;
				break;
			}
		}
	}
	if (flag==false)
	{
		alert("请先选择要删除的店铺！");
		return false;
	}
	document.thisForm.target='_self';	

	if (id==1)
	{
		if(confirm("您确定要删除选中的店铺信息吗？")==true)
		{
			document.thisForm.action="del_shop_all.php?page=<?php echo $page;?>";
			thisForm.submit();
		}
	}
}
</script>
</head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" width="100%" height="207" style="border:1px  solid #DCEAF7;">
            <tr>
              <td width="358" height="30" align="left" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="../images/arrow.gif" width="16" height="22" align="absmiddle" /> 淘宝店铺管理 </strong></td>
              <form id="form2" name="form2" method="get" action="">
              <td width="479" align="left" bgcolor="E9F2FB" class="bigtext">掌柜或店铺名
                  <input type="text" class="button3" name="keyword" value="<?=$keyword?>" />
                 <select name="dj" id="dj">
				 <option value=""<?php if($dj=='') echo ' selected';?>>等级不限</option>
				  <option value="1"<?php if($dj=='1') echo ' selected';?>>一心</option>
				  <option value="2"<?php if($dj=='2') echo ' selected';?>>两心</option>
				  <option value="3"<?php if($dj=='3') echo ' selected';?>>三心</option>
				  <option value="4"<?php if($dj=='4') echo ' selected';?>>四心</option>
				  <option value="5"<?php if($dj=='5') echo ' selected';?>>五心</option>
				  <option value="6"<?php if($dj=='6') echo ' selected';?>>一钻</option>
				  <option value="7"<?php if($dj=='7') echo ' selected';?>>两钻</option>
				  <option value="8"<?php if($dj=='8') echo ' selected';?>>三钻</option>
				  <option value="9"<?php if($dj=='9') echo ' selected';?>>四钻</option>
				  <option value="10"<?php if($dj=='10') echo ' selected';?>>五钻</option>
				  <option value="11"<?php if($dj=='11') echo ' selected';?>>一冠</option>
				  <option value="12"<?php if($dj=='12') echo ' selected';?>>两冠</option>
				  <option value="13"<?php if($dj=='13') echo ' selected';?>>三冠</option>
				  <option value="14"<?php if($dj=='14') echo ' selected';?>>四冠</option>
				  <option value="15"<?php if($dj=='15') echo ' selected';?>>五冠</option>
				  <option value="16"<?php if($dj=='16') echo ' selected';?>>一金冠</option>
				  <option value="17"<?php if($dj=='17') echo ' selected';?>>二金冠</option>
				  <option value="18"<?php if($dj=='18') echo ' selected';?>>三金冠</option>
				  <option value="19"<?php if($dj=='19') echo ' selected';?>>四金冠</option>
				  <option value="20"<?php if($dj=='20') echo ' selected';?>>五金冠</option>
				</select>

                <input type="submit" name="Submit" value="查找" />
                </td></form>
              <td width="130" height="30" align="right" bgcolor="E9F2FB" class="bigtext">共有 <b><?php echo $total;?></b> 条记录&nbsp;&nbsp;</td>
            </tr>
            <tr>
              <td colspan="3" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><FORM name="thisForm" action="" method=post><table width="100%" border=1 cellpadding=0 cellspacing=0 style="border-collapse: collapse" bordercolor="#dddddd">
                    <tr>
					  <td width="3%" bgcolor="#F2F2F2"><input type="checkbox" name="mycheck" id="mycheck" value="checkbox" onclick="SelectAll()"/></td>
                      <td width="20%" align=center height="30" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;掌柜名称</strong></td>
                      <td width="22%" bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;店铺名称</strong></td>
                      <td width="12%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;店铺等级 <?php if($px=="1"){echo "<a href=\"shoplist.php?keyword=".urlencode($keyword)."&dj=".$dj."&px=0\"><img src='images/drop.gif' title='向下排序'/></a>";}else{echo "<a href=\"shoplist.php?keyword=".urlencode($keyword)."&dj=".$dj."&px=1\"><img src='images/up.gif' title='向上排序'/></a>";}?></strong></td>
					  <td width="10%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;所在地</strong></td>
                      <td width="10%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>店铺类别</strong></td>
                      <td width="10%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>采集时间</strong></td>
                      <td width="13%" align=center bgcolor="#F2F2F2" class="bigtext"><strong>&nbsp;执行操作</strong></td>
                      </tr>
                    <?php
					while ($row = mysql_fetch_array($rs))
					{
					if($row["type"]=="C"){
						$shoptype="普通商家";
					}else{
						$shoptype="商城卖家";
					}
						echo "<tr>";
						echo "<td><input type=\"checkbox\" name=\"fu[]\" id=\"fu[]\" value=".$row["Id"]." /></td>";
                      	echo "<td align=center height=30 class=bigtext>&nbsp;<a href=\"../shop.php?nick=".urlencode($row["nick"])."\" class=\"bigtext\" target=\"_blank\">".$row["nick"]."</a></td>";
                      	echo "<td height=30 class=bigtext><div style=\"width:300px; overflow:hidden; margin-left:5px; text-align:left; height:20px; line-height:20px;\"><a href=\"../shop.php?nick=".urlencode($row["nick"])."\" class=\"bigtext\" target=\"_blank\">".$row["title"]."</a></div></td>";
						echo "<td align=center class=bigtext>&nbsp;<img src=../images/level_".$row["level"].".gif alt=\"等级".$row["level"]."\" /></td>";
						echo "<td align=center class=bigtext>&nbsp;".$row["city"]."</td>";
						echo "<td align=center class=bigtext >&nbsp;".$shoptype."</td>";				
						echo "<td align=center class=bigtext>&nbsp;".date("Y-m-d",$row["addtime"])."</td>";
						if($row["tuijian"]!='0'){$ontop="<font color=#ff0000>顶</font>";}else{$ontop="顶";}
						echo "<td align=center class=bigtext>&nbsp;<a onclick=\"return confirm('您确定要置顶该店铺吗?')\" href=chgshop.php?top=1&id=".$row["Id"]." class=link4>".$ontop."</a> <a onclick=\"return confirm('您确定要取消置顶该店铺吗?')\" href=chgshop.php?top=0&id=".$row["Id"]." class=link4>消</a> | <a href=delshop.php?id=".$row["Id"]." class=link4>删除</a></td>";
						echo "</tr>";
					}
					?></table><br>
                  <input name="delall" type="button" id="delall" onclick="javascript:showconfirm(1)" value="批量删除"/></FORM>
                   <div class="yahoo2" style=" margin-top:30px;"><?php 
				pageft($total,$pagesize,1,1,0,10,"shoplist.php?keyword=".urlencode($keyword)."&dj=".$dj."&px=".$px."");
				echo $pagenav;?></div>
                  </td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
</body>
</html>
<?php mysql_close($link);?>
